package com.atguigu.spring6.iocxml.ditest;

import com.atguigu.spring6.iocxml.dimap.Student;
import org.springframework.context.ApplicationContext;

/**
 * @author: Michael
 * @date: 2025/5/13
 * @desc:
 */
public class TestEmp {

    public static void main(String[] args) {
//        diArray();
//        diList();
//        diMap();
//        diRef();
        diRef2();
    }

    public static void diTest(){
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-ditest.xml");
//        Emp emp = context.getBean("emp", Emp.class);
        //        emp.work();
//        Emp emp2 = context.getBean("emp2", Emp.class);
//        emp2.work();
        Emp emp3 = context.getBean("emp3", Emp.class);
        emp3.work();
    }

    public static void diArray () {
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-diarray.xml");
        Emp emp = context.getBean("emp", Emp.class);
        emp.work();
    }

    public static void diList () {
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-dilist.xml");
        Dept dept = context.getBean("dept", Dept.class);
        dept.info();
    }

    public static void diMap () {
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-dimap.xml");
        Student student = context.getBean("student", Student.class);
        student.run();
    }

    public static void diRef () {
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-diref.xml");
        Student student = context.getBean("student", Student.class);
        student.run();
    }

    public static void diRef2 () {
        ApplicationContext context = new org.springframework.context.support.ClassPathXmlApplicationContext("bean-diref.xml");
        Student student = context.getBean("studentP", Student.class);
        student.run();
    }
}
